package com.vic.hello_world;

import com.rabbitmq.client.Channel;
import com.vic.utils.RabbitmqUtils;

import java.nio.charset.StandardCharsets;

/**
 * 发送者
 */
public class Producer {

    // 队列名称
    private final static String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitmqUtils.getChannel();

        // 声明队列
        /**
         * 各参数的说明，请参考Technology/RabbitMQ/rabbitmq系列
         */
        channel.queueDeclare(QUEUE_NAME, false, false, false , null);

        // 消息
        String msg = "hello";

        // 发送消息
        channel.basicPublish("", QUEUE_NAME, null, msg.getBytes(StandardCharsets.UTF_8));

        System.out.println("消息发送完毕");
    }

}
